<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;

class User extends Controller
{
    public function showlogin(){
        return view('admin.index.showlogin');
    }

    public function login(Request $request){

        $params = $this->validate($request,[
            'username'=>'required',
            'password'=>'required'
        ]);

       $bool = auth()->attempt($params);
       if ($bool){
           return redirect('index');
       }
       return redirect('showlogin')->withErrors('用户名或密码错误');
    }



}
